package com.neusoft.yuejian_01.activity.MJJ;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.LinearLayout;

import com.neusoft.yuejian_01.R;

public class WelcomeActivity extends Activity {
    private LinearLayout leftLayout;
    private LinearLayout rightLayout;
    private LinearLayout animLayout;

//动画，拉开始
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);//隐藏标题栏
        setContentView(R.layout.activity_welcome);
        init();
    }
    private void init() {
        this.animLayout = (LinearLayout)this.findViewById(R.id.animLayout);
        this.leftLayout = (LinearLayout)this.findViewById(R.id.leftLayout);
        this.rightLayout = (LinearLayout)this.findViewById(R.id.rightLayout);
        this.animLayout.setBackgroundResource(R.drawable.main_bg);
        //绑定好部件，进行动画位置和速度设计。
        Animation leftOutAnimation = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.translate_left);
        Animation rightOutAnimation = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.translate_right);
        this.leftLayout.setAnimation(leftOutAnimation);
        this.rightLayout.setAnimation(rightOutAnimation);
        //动画开始监听
        leftOutAnimation.setAnimationListener(new AnimationListener() {
            public void onAnimationStart(Animation animation) {
            }

            public void onAnimationRepeat(Animation animation) {
            }

            public void onAnimationEnd(Animation animation) {
                WelcomeActivity.this.leftLayout.setVisibility(View.GONE);
                WelcomeActivity.this.rightLayout.setVisibility(View.GONE);
                Intent intent = new Intent();
                intent.setClass(WelcomeActivity.this, AccessActivity.class);
                WelcomeActivity.this.startActivity(intent);
                WelcomeActivity.this.overridePendingTransition(0, 0);
                WelcomeActivity.this.finish();
            }
        });
    }
}

